package BouncingBallControlledPackage model ControlledBouncingMass BouncingBallControlledPackage.Controller controller1 annotation(Placement(visible = true, transformation(origin = {-59.0616,47.8381}, extent = {{-12,-12},{12,12}}, rotation = 0))); BouncingBallControlledPackage.BouncingMass bouncingmass1 annotation(Placement(visible = true, transformation(origin = {22.6311,50.046}, extent = {{-12,-12},{12,12}}, rotation = 0))); annotation(experiment(StartTime = 0.0, StopTime = 5.0, Tolerance = 0.000001)); equation connect(controller1.flange_b,bouncingmass1.flange_a) annotation(Line(points = {{-51.4002,50.311},{11.7755,50.311},{11.7755,49.494},{11.724,49.494}})); end ControlledBouncingMass; model Controller Modelica.Mechanics.Translational.Sources.Force u annotation(Placement(visible = true, transformation(origin = {-13.4315,62.0055}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Blocks.Sources.Pulse pulseControl(amplitude = -1000, period = 2.14, offset = 0, width = 1) annotation(Placement(visible = true, transformation(origin = {-76.3569,60.7176}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Mechanics.Translational.Interfaces.Flange_b flange_b annotation(Placement(visible = true, transformation(origin = {63.8454,20.6072}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {63.8454,20.6072}, extent = {{-12,-12},{12,12}}, rotation = 0))); annotation(Diagram(), Icon()); equation connect(u.flange,flange_b) annotation(Line(points = {{-1.4315,62.0055},{64.0294,62.0055},{64.0294,20.6072},{63.8454,20.6072}})); connect(pulseControl.y,u.f) annotation(Line(points = {{-63.1569,60.7176},{-29.2548,60.7176},{-29.2548,62.0055},{-27.8315,62.0055}})); end Controller; model ImpulsiveControllerBouncingMass BouncingBallControlledPackage.impulsiveController impulsivecontroller1 annotation(Placement(visible = true, transformation(origin = {-66.6053,34.7746}, extent = {{-12,-12},{12,12}}, rotation = 0))); BouncingBallControlledPackage.BouncingMass bouncingmass1 annotation(Placement(visible = true, transformation(origin = {37.9025,38.8224}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Mechanics.Translational.Sources.Force force1 annotation(Placement(visible = true, transformation(origin = {-17.6633,37.1665}, extent = {{-12,-12},{12,12}}, rotation = 0))); annotation(experiment(StartTime = 0.0, StopTime = 10, Tolerance = 0.000001)); equation connect(bouncingmass1.v,impulsivecontroller1.velocity) annotation(Line(points = {{49.0966,33.2806},{78.0129,33.2806},{78.0129,14.5354},{-81.5087,14.5354},{-81.5087,35.3266},{-77.4462,35.3266},{-77.4462,35.5032}})); connect(bouncingmass1.s,impulsivecontroller1.position) annotation(Line(points = {{49.7369,35.6872},{82.4287,35.6872},{82.4287,-22.9991},{-95.3082,-22.9991},{-95.3082,40.1104},{-77.8436,40.1104},{-77.8436,40.0957}})); connect(force1.flange,bouncingmass1.flange_a) annotation(Line(points = {{-5.66329,37.1665},{27.2309,37.1665},{27.2309,38.2705},{26.9954,38.2705}})); connect(impulsivecontroller1.force,force1.f) annotation(Line(points = {{-55.4112,37.7994},{-33.3027,37.7994},{-33.3027,37.1665},{-32.0633,37.1665}})); end ImpulsiveControllerBouncingMass; model BouncingMass BouncingBallControlledPackage.FallingMass fallingmass1 annotation(Placement(visible = true, transformation(origin = {-11.9595,40.4784}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Mechanics.Translational.Interfaces.Flange_a flange_a annotation(Placement(visible = true, transformation(origin = {-90.8924,-4.59982}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {-90.8924,-4.59982}, extent = {{-12,-12},{12,12}}, rotation = 0))); annotation(Diagram(), Icon()); Modelica.Mechanics.Translational.Interfaces.Flange_b flange_b annotation(Placement(visible = true, transformation(origin = {94.9402,-1.65593}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {94.9402,-1.65593}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Blocks.Interfaces.RealOutput s annotation(Placement(visible = true, transformation(origin = {98.6201,-26.127}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {98.6201,-26.127}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Blocks.Interfaces.RealOutput v annotation(Placement(visible = true, transformation(origin = {93.2843,-46.1822}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {93.2843,-46.1822}, extent = {{-12,-12},{12,12}}, rotation = 0))); equation connect(fallingmass1.v,v) annotation(Line(points = {{-0.544596,35.0469},{84.0846,35.0469},{84.0846,-46.1822},{93.2843,-46.1822}})); connect(fallingmass1.s,s) annotation(Line(points = {{-0.279648,38.3146},{89.6044,38.3146},{89.6044,-26.127},{98.6201,-26.127}})); connect(fallingmass1.flange_b,flange_b) annotation(Line(points = {{-2.0239,41.4278},{94.0202,41.4278},{94.0202,-1.65593},{94.9402,-1.65593}})); connect(flange_a,fallingmass1.flange_a) annotation(Line(points = {{-90.8924,-4.59982},{-21.8951,-4.59982},{-21.8951,41.1849},{-21.7847,41.1849}})); when s <= 0 then reinit(fallingmass1.mass.v, -fallingmass1.mass.v * 0.5); end when; end BouncingMass; model SystemPlantController BouncingBallControlledPackage.Plant plant1 annotation(Placement(visible = true, transformation(origin = {48.758,25.207}, extent = {{-12,-12},{12,12}}, rotation = 0))); BouncingBallControlledPackage.impulsiveController impulsivecontroller1 annotation(Placement(visible = true, transformation(origin = {-23.919,22.0791}, extent = {{-12,-12},{12,12}}, rotation = 0))); annotation(experiment(StartTime = 0.0, StopTime = 5.0, Tolerance = 0.000001)); equation connect(plant1.v,impulsivecontroller1.velocity) annotation(Line(points = {{60.173,19.7755},{67.1573,19.7755},{67.1573,-26.6789},{-58.3257,-26.6789},{-58.3257,22.4471},{-34.7599,22.4471},{-34.7599,22.8077}})); connect(plant1.s,impulsivecontroller1.position) annotation(Line(points = {{60.4379,23.0432},{80.7728,23.0432},{80.7728,-38.6385},{-78.1969,-38.6385},{-78.1969,27.4149},{-35.1573,27.4149},{-35.1573,27.4002}})); connect(impulsivecontroller1.force,plant1.u) annotation(Line(points = {{-12.7249,25.104},{36.9825,25.104},{36.9825,18.1637},{37.7847,18.1637}})); end SystemPlantController; model Plant Modelica.Mechanics.Translational.Components.Mass mass(m = 1, s(start = 10)) annotation(Placement(visible = true, transformation(origin = {29.2548,52.2539}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Mechanics.Translational.Sources.Force gravitationalForce annotation(Placement(visible = true, transformation(origin = {-16.1914,53.3579}, extent = {{-12,-12},{12,12}}, rotation = 0))); annotation(Diagram(), Icon(), experiment(StartTime = 0.0, StopTime = 10.0, Tolerance = 0.000001)); Modelica.Blocks.Interfaces.RealOutput s annotation(Placement(visible = true, transformation(origin = {97.3321,-18.0313}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {97.3321,-18.0313}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Blocks.Interfaces.RealOutput v annotation(Placement(visible = true, transformation(origin = {95.1242,-45.2622}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {95.1242,-45.2622}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Blocks.Interfaces.RealInput u annotation(Placement(visible = true, transformation(origin = {-91.4443,-58.6937}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {-91.4443,-58.6937}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Mechanics.Translational.Sources.Force controlForce annotation(Placement(visible = true, transformation(origin = {-46.3661,-58.3257}, extent = {{-12,-12},{12,12}}, rotation = 0))); constant Real gravitionalAcceleration = 9.81 annotation(Placement(visible = true, transformation(origin = {81.5087,-84.6366}, extent = {{-12,-12},{12,12}}, rotation = 0))); parameter Real restCoef = 0.5 annotation(Placement(visible = true, transformation(origin = {53.1739,-85.3726}, extent = {{-12,-12},{12,12}}, rotation = 0))); equation connect(controlForce.flange,mass.flange_a) annotation(Line(points = {{-34.3661,-58.3257},{17.2953,-58.3257},{17.2953,52.2539},{17.2548,52.2539}})); connect(u,controlForce.f) annotation(Line(points = {{-91.4443,-58.6937},{-61.4535,-58.6937},{-61.4535,-58.3257},{-60.7661,-58.3257}})); connect(gravitationalForce.flange,mass.flange_a) annotation(Line(points = {{-4.19135,53.3579},{17.1113,53.3579},{17.1113,52.2539},{17.2548,52.2539}})); assert(mass.m > 0, "out of domain of validity"); s = mass.s; v = mass.v; gravitationalForce.f = -gravitionalAcceleration; when mass.s <= 0 then reinit(mass.v, -mass.v * restCoef); end when; end Plant; model FallingMass Modelica.Mechanics.Translational.Components.Mass mass(m = 1, s(start = 10)) annotation(Placement(visible = true, transformation(origin = {29.2548,52.2539}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Mechanics.Translational.Sources.Force gravitationalForce annotation(Placement(visible = true, transformation(origin = {-16.1914,53.3579}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Blocks.Sources.Constant gravitationalAcceleration(k = -9.81) annotation(Placement(visible = true, transformation(origin = {-56.8537,52.4379}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Mechanics.Translational.Interfaces.Flange_a flange_a annotation(Placement(visible = true, transformation(origin = {-81.8767,5.88776}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {-81.8767,5.88776}, extent = {{-12,-12},{12,12}}, rotation = 0))); annotation(Diagram(), Icon()); Modelica.Mechanics.Translational.Interfaces.Flange_b flange_b annotation(Placement(visible = true, transformation(origin = {82.7967,7.91168}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {82.7967,7.91168}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Mechanics.Translational.Sensors.PositionSensor positionsensor annotation(Placement(visible = true, transformation(origin = {55.7498,-14.5354}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Mechanics.Translational.Sensors.SpeedSensor speedsensor annotation(Placement(visible = true, transformation(origin = {54.8298,-43.6063}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Blocks.Interfaces.RealOutput s annotation(Placement(visible = true, transformation(origin = {97.3321,-18.0313}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {97.3321,-18.0313}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Blocks.Interfaces.RealOutput v annotation(Placement(visible = true, transformation(origin = {95.1242,-45.2622}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {95.1242,-45.2622}, extent = {{-12,-12},{12,12}}, rotation = 0))); equation connect(mass.flange_b,speedsensor.flange) annotation(Line(points = {{41.2548,52.2539},{42.6863,52.2539},{42.6863,-43.6063},{42.8298,-43.6063}})); connect(mass.flange_b,positionsensor.flange) annotation(Line(points = {{41.2548,52.2539},{43.2383,52.2539},{43.2383,-14.5354},{43.7498,-14.5354}})); connect(speedsensor.v,v) annotation(Line(points = {{68.0298,-43.6063},{89.6044,-43.6063},{89.6044,-45.2622},{95.1242,-45.2622}})); connect(positionsensor.s,s) annotation(Line(points = {{68.9498,-14.6554},{88.3165,-14.6554},{88.3165,-18.0313},{97.3321,-18.0313}})); connect(mass.flange_a,flange_a) annotation(Line(points = {{17.2548,52.2539},{16.7433,52.2539},{16.7433,5.88776},{-81.8767,5.88776}})); connect(mass.flange_b,flange_b) annotation(Line(points = {{41.2548,52.2539},{81.8767,52.2539},{81.8767,7.91168},{82.7967,7.91168}})); assert(mass.m > 0, "out of domain of validity"); connect(gravitationalAcceleration.y,gravitationalForce.f) annotation(Line(points = {{-43.6537,52.4379},{-32.3827,52.4379},{-32.3827,53.3579},{-30.5914,53.3579}})); connect(gravitationalForce.flange,mass.flange_a) annotation(Line(points = {{-4.19135,53.3579},{17.1113,53.3579},{17.1113,52.2539},{17.2548,52.2539}})); end FallingMass; model impulsiveController Modelica.Blocks.Interfaces.RealInput position annotation(Placement(visible = true, transformation(origin = {-93.6523,44.3422}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {-93.6523,44.3422}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Blocks.Interfaces.RealInput velocity annotation(Placement(visible = true, transformation(origin = {-90.3404,6.07176}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {-90.3404,6.07176}, extent = {{-12,-12},{12,12}}, rotation = 0))); Modelica.Blocks.Interfaces.RealOutput force annotation(Placement(visible = true, transformation(origin = {93.2843,25.207}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {93.2843,25.207}, extent = {{-12,-12},{12,12}}, rotation = 0))); //parameter Real ref = 10 annotation(Placement(visible = true, transformation(origin = {79.1168,-80.4048}, extent = {{-12,-12},{12,12}}, rotation = 0))); //parameter Real restCoef = 0.5 annotation(Placement(visible = true, transformation(origin = {46.7341,-81.5087}, extent = {{-12,-12},{12,12}}, rotation = 0))); //parameter Real K = 1800; parameter Real epsilon = 0.01 annotation(Placement(visible = true, transformation(origin = {15.8234,-82.2447}, extent = {{-12,-12},{12,12}}, rotation = 0))); equation when sample(0, 0.01) then if 0 <= velocity and velocity <= epsilon and epsilon <= position then force = -24254; else force = 0; end if; end when; //-((ref - position) * K) / restCoef; end impulsiveController; end BouncingBallControlledPackage;